package sundun.sharding.controller;

import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sundun.sharding.entity.ImsSysCenterOrg;
import sundun.sharding.entity.ImsYesterdayJqxx;
import sundun.sharding.mapper.ImsSysCenterOrgDao;
import sundun.sharding.mapper.ImsYesterdayJqxxDao;

import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/admin")
public class ImsYesyerdayJqxxController {

    @Autowired
    private ImsYesterdayJqxxDao imsYesterdayJqxxDao;


    @Autowired
    private ImsSysCenterOrgDao imsSysCenterOrgDao;


//    @GetMapping(value = "/interaction")
//    @DataSource(DataSourceType.SLAVE)
//    @Transactional(rollbackFor = Exception.class)
//    public void queryInteractionStatistics(){
//        ImsYesterdayJqxx imsYesterdayJqxx = new ImsYesterdayJqxx();
//        imsYesterdayJqxx.setGxdwbh("21020300001");
//        imsYesterdayJqxx.setBjsj(new Date());
//        imsYesterdayJqxxDao.insert(imsYesterdayJqxx);
////        int i = 1/0;
//    }
//
//    @GetMapping(value = "/interaction-master")
//    @DataSource(DataSourceType.MASTER)
//    @Transactional(rollbackFor = Exception.class)
//    public void queryInteractionStatistics8(){
//        ImsYesterdayJqxx imsYesterdayJqxx = new ImsYesterdayJqxx();
//        imsYesterdayJqxx.setGxdwbh("21020300001");
//        imsYesterdayJqxx.setBjsj(new Date());
//        imsYesterdayJqxxDao.insert(imsYesterdayJqxx);
//        int i = 1/0;
//    }


    @GetMapping(value = "/interaction1")
    public void queryInteractionStatistics1(){
        for (int i = 0; i < 2; i++) {
            ImsYesterdayJqxx imsYesterdayJqxx = new ImsYesterdayJqxx();
            imsYesterdayJqxx.setGxdwbh("21020300001"+i);
            imsYesterdayJqxx.setBjsj(new Date());
            imsYesterdayJqxxDao.insert1(imsYesterdayJqxx);
        }
    }

//    @DataSource(name="origin")
    @GetMapping(value = "/interaction2")
    public void queryInteractionStatistics2(){
        imsYesterdayJqxxDao.selectList(null);
    }

    @GetMapping(value = "/interaction5")
    public void queryInteractionStatistics5(){
//        LambdaQueryWrapper<ImsYesterdayJqxx> eq = Wrappers.<ImsYesterdayJqxx>lambdaQuery().eq(ImsYesterdayJqxx::getJqbh, "J999969");
//        List<ImsYesterdayJqxx> imsYesterdayJqxxes = imsYesterdayJqxxDao.selectList(eq);
//        System.out.println(JSON.toJSONString(imsYesterdayJqxxes));
    }


//    @DataSource(name="ds0")
    @GetMapping(value = "/interaction3")
    public void queryInteractionStatistics3(){
        imsSysCenterOrgDao.selectList(null);
    }

    @GetMapping(value = "/interaction4")
    public void queryInteractionStatistics4(){
        ImsSysCenterOrg imsYesterdayJqxx = new ImsSysCenterOrg();
        imsYesterdayJqxx.setCenterId("21020300001");
        imsYesterdayJqxx.setId("222");
        imsSysCenterOrgDao.insert(imsYesterdayJqxx);
    }
}
